home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs53.d81 / 28may87s.pma / CXEM.ASM < prev    next >
Assembly Source File  |  1979-12-31  |  10KB  |  607 lines

  1.  
  2.  
  3.     title    'Terminal Emulation (ADM-31 with K-Pro support)   21 May 86'
  4.  
  5.  
  6.     maclib    z80
  7.  
  8.     maclib    cxequ
  9.  
  10. lines    equ    24
  11.  
  12.     public    ?out40,?out80,ADM31
  13.  
  14. ;
  15. ;    ADM3A
  16. ;
  17. ;
  18. ;    ESC = row col        cursor position
  19. ;    ESC ESC ESC color    set color        ; added for C128 CP/M
  20. ;    ^H            cursor left
  21. ;    ^L            cursor right
  22. ;    ^J            cursor down
  23. ;    ^K            cursor up
  24. ;    ^Z            home and clear screen
  25. ;    ^M            carrage return
  26. ;    ^G            bell
  27.  
  28. ;
  29. ;    ADM31
  30. ;
  31. ;
  32. ;    ESC = row col    cursor position
  33. ;    ESC ESC ESC color    set color        ; added for C128 CP/M
  34. ;    ESC T        clear to end of line
  35. ;    ESC t        clear to end of line
  36. ;    ESC Y        clear to end of screen
  37. ;    ESC y        clear to end of screen
  38. ;    ESC :        home & clear screen
  39. ;    ESC *        home & clear screen
  40. ;    ESC )        Half intensity on
  41. ;    ESC (        Half intensity off
  42. ;    ESC G 4        Reverse video on
  43. ;    ESC G 2        Blinking on
  44. ;    ESC G 0        Rev. video and blinking off
  45. ;    ESC E        Insert line
  46. ;    ESC Q        Insert Character
  47. ;    ESC R        Delete Line
  48. ;    ESC W        Delete Character
  49. ;    ^H        cursor left
  50. ;    ^L        cursor right
  51. ;    ^J        cursor down
  52. ;    ^K        cursor up
  53. ;    ^Z        home and clear screen
  54. ;    ^M        carriage return
  55. ;    ^G        bell
  56. ;
  57.     page
  58. ;
  59. ;    KPRO II Terminal control sequences
  60. ;
  61. ;
  62. ; Cursor Control
  63. ;
  64. ;    ^H    cursor left (bs)
  65. ;    ^L    cursor right
  66. ;    ^J    cursor down
  67. ;    ^K    cursor up
  68. ;    ^^    home cursor
  69. ;    ^Z    home cursor & clear screen
  70. ;    ^M    carriage return
  71. ;
  72. ; Cursor Positioning
  73. ;
  74. ;    ESC = R C    (R & C =' '+position)
  75. ;
  76. ; Line Insert/Delete
  77. ;
  78. ;    ESC E    Line Insert
  79. ;    ESC R    Line Delete
  80. ;
  81. ; Clear to End of Screen/Line
  82. ;
  83. ;    ^X    Clear to End of Line
  84. ;    ^W    Clear to End of Screen
  85. ;
  86. ; Set Greek or ASCII (not supported)
  87. ;
  88. ;    ESC A    Set ASCII
  89. ;    ESC G    Set Greek    (lower case letters print as Greek Alphabet)
  90. ;
  91. ; KAYPRO 84 (???) screen commands
  92. ;
  93. ;    ESC B <num>    turn attrubute on
  94. ;    ESC C <num>    turn attrubute off
  95. ;
  96. ;    where <num> is defined as:
  97. ;        0=reverse video
  98. ;        1=    <half intensity>
  99. ;        2=    <blink>
  100. ;        3=    <underline>
  101. ;
  102. ;            <best guess>
  103. ;
  104. ;        The following two sequences are
  105. ;         use but I do not know what function
  106. ;         they perform.  (added 21 May 86)
  107. ;
  108. ;    ESC D <num1><num2><num3><num4>
  109. ;    ESC L <num1><num2><num3><num4>
  110. ;
  111.     page
  112.  
  113.     dseg
  114. ;
  115. ;
  116. ;
  117. ?out40:
  118.     mvi    a,FR$40
  119.     lxi    h,parm$area$40
  120.     jr    out$cont
  121.  
  122. ;
  123. ;
  124. ;
  125. ?out$80:
  126.     xra    a            ; 80 column offset is 0
  127.     lxi    h,parm$area$80
  128. out$cont:
  129.     sta    fun$offset
  130.     mvi    a,7fh
  131.     ana    c
  132.     mov    c,a
  133.     shld    parm$base
  134.     lhld    emulation$adr
  135.     pchl
  136.  
  137.     page
  138. ;
  139. ;    ADM-31 terminal emulation
  140. ;
  141. ADM31:
  142.     lhld    parm$base        ; 1st parm is exec adr (2 bytes)
  143.     mov    a,m
  144.     inx    h
  145.     mov    h,m
  146.     mov    l,a
  147.  
  148.     ora    h            ; L is in A already, test HL=0
  149.     mov    a,c            ; C is char to output
  150.     jrz    start$checking 
  151.     pchl
  152.  
  153. ;
  154. ;
  155. ;
  156. start$checking:
  157.     lxi    h,control$table
  158.     lxi    b,cnt$tbl$lng
  159.     ccir
  160.     lxi    h,control$exec$adr
  161.     jrz    find$exec$adr
  162.  
  163.     cpi    20h
  164.     rc
  165.  
  166. do$direct:
  167.     mov    d,a
  168.     TJMP    FR$wr$char
  169.  
  170.     page
  171. ;
  172. ;
  173. ;
  174. char$esc:                ; ESC
  175.     call    cont$later
  176. ;
  177. ;    ESC char    look for char in the ESC table
  178. ;
  179.     call    remove$exec$adr
  180.     lxi    h,esc$table
  181.     lxi    b,esc$tbl$lng
  182.     ccir
  183.     rnz                ; bad esc sequence
  184.     lxi    h,esc$exec$adr
  185.  
  186. find$exec$adr:
  187.     dad    b
  188.     dad    b
  189.     mov    a,m
  190.     inx    h
  191.     mov    h,m
  192.     mov    l,a
  193.     pchl
  194.  
  195.  
  196.  
  197.     page
  198. ;
  199. ;
  200. ;
  201. cont$later:
  202.     pop    h        ; get address to cont at in H
  203.     jr    save$exec$adr    ; save it
  204. ;
  205. ;
  206. ;
  207. remove$exec$adr:
  208.     lxi    h,0
  209. save$exec$adr:
  210.     xchg
  211.     lhld    parm$base
  212.     mov    m,e
  213.     inx    h
  214.     mov    m,d
  215.     ret
  216.  
  217.  
  218. ;
  219. ;
  220. ;
  221. esc$esc:
  222.     call    cont$later
  223. ;
  224. ;    check for ESC ESC ESC
  225. ;
  226.     cpi    esc            ; check if 3rd char is an ESC
  227.     jrnz    remove$exec$adr
  228.     call    cont$later
  229. ;
  230. ;    set current character as the attr
  231. ;
  232.     mov    b,a
  233.     TCALL    FR$color
  234.     jr    remove$exec$adr
  235.  
  236.     page
  237. ;
  238. ;
  239. ;
  240. esc$equ:
  241.     call    cont$later
  242. ;
  243. ;    ESC = R
  244. ;
  245.     lhld    parm$base
  246.     inx    h
  247.     inx    h
  248.     sui    ' '            ; remove ascii bias
  249.     mov    m,a
  250.     cpi    '8'-' '            ; test for line 25 (A=24?)
  251.     jrnz    not$status$line        ; no, jmp
  252.     inr    a            ; yes, A=25
  253.     sta    paint$size        ; set 40 column repaint to 25 lines
  254. not$status$line:
  255.     call    cont$later
  256. ;
  257. ;    ESC = R C    (go do it)
  258. ;
  259.     sui    ' '
  260.     mov    e,a            ; column # to E
  261.  
  262.     lhld    parm$base
  263.     inx    h
  264.     inx    h
  265.     mov    d,m            ; row # to D
  266.     TCALL    FR$cursor$pos
  267.     jr    remove$exec$adr
  268.  
  269.     page
  270. ;
  271. ;
  272. ;
  273. char$cnt$z:                ; ^Z    home and clear screen
  274.     lxi    d,lines*256+0        ; B=24(row) C=0(col)
  275.     TCALL    FR$cursor$pos
  276.     call    esc$t            ; clear the status line 
  277.     lxi    d,0
  278.     TCALL    FR$cursor$pos
  279. esc$y:
  280.     TJMP    FR$CES            ; clear to end of screen 
  281.  
  282. home$cursor:
  283.     lxi    d,0
  284.     TJMP    FR$cursor$pos
  285.     
  286. esc$t:
  287.     TJMP    FR$CEL            ; clear to end of line 
  288.  
  289. ;
  290. ;
  291. ;
  292. do$cr:
  293.     TJMP    FR$do$cr
  294.  
  295. ;
  296. ;
  297. ;
  298. cursor$rt:
  299.     TJMP    FR$cursor$rt
  300.  
  301. ;
  302. ;
  303. ;
  304. cursor$up:
  305.     TJMP    FR$cursor$up
  306.  
  307. ;
  308. ;
  309. ;
  310. cursor$down:
  311.     TJMP    FR$cursor$down
  312.  
  313. ;
  314. ;
  315. ;
  316. cursor$left:
  317.     TJMP    FR$cursor$left
  318.  
  319.     page
  320.  
  321. ;
  322. ;    placed in common so that link and gencpm will not
  323. ;    cause this code to show up at address 0D000h to 0DFFFh
  324. ;
  325. char$cnt$g:                ; ^G    bell
  326.     RJMP    FR$bell
  327.  
  328. ;
  329. ;    delete character
  330. ;
  331. esc$W:
  332.     TJMP    FR$char$del
  333.  
  334. ;
  335. ;    delete line
  336. ;
  337. esc$R:
  338.     TJMP    FR$line$del
  339.  
  340. ;
  341. ;    insert character
  342. ;
  343. esc$Q:
  344.     TJMP    FR$char$ins
  345.  
  346. ;
  347. ;    insert line
  348. ;
  349. esc$E:
  350.     TJMP    FR$line$ins
  351.  
  352.     page
  353. ;
  354. ;    ESC C <num> atribute off
  355. ;
  356. esc$C:
  357.     call    cont$later
  358.     lxi    b,4*256+4        ; max+1 num, offset
  359.     jr    esc$num$cont
  360.  
  361. ;
  362. ;    ESC B <num> atribute on
  363. ;
  364. esc$B:
  365.     call    cont$later
  366.     lxi    b,4*256+0        ; max+1 num, offset
  367.     jr    esc$num$cont
  368. ;
  369. ;    Set Attribute sequence
  370. ;
  371. esc$G:
  372.     call    cont$later
  373.     lxi    b,5*256+8        ; max+1 num, table offset
  374. esc$num$cont:
  375.     call    remove$exec$adr
  376.     sui    '0'            ; remove ascii bias
  377.     cmp    b            ; number of functions
  378.     rnc
  379.     add    c            ; get offset
  380.     mov    c,a
  381.     mvi    b,0
  382.     lxi    h,esc$num$tbl
  383.     jmp    find$exec$adr
  384.  
  385.     page
  386. ;
  387. ;
  388. ;
  389. esc$D:
  390. esc$L:
  391.     call    cont$later        ; wait for num1
  392.     call    cont$later        ; wait for num2
  393.     call    cont$later        ; wait for num3
  394.     call    cont$later        ; wait for num4 
  395.     jmp    remove$exec$adr
  396.  
  397.     page
  398. ;
  399. ;    Half Intensity Off
  400. ;
  401. esc$lfp:
  402.     mvi    b,00000001b        ; turn intensity up
  403.     jr    set$atr$on
  404. ;
  405. ;    Half Intensity On
  406. ;
  407. esc$rtp:
  408.     mvi    b,00000001b        ; turn intensity down
  409.     jr    set$atr$off
  410.  
  411. ;
  412. ;    Rev. Video, blink, atl char set, and underline  off
  413. ;
  414. esc$G$0:
  415.     mvi    c,10000000b        ; turn attributes off
  416.     mvi    b,11110000b        ; attribute bit to change
  417.     jr    set$FR$attr
  418.  
  419. ;
  420. ;    Select alt character set
  421. ;
  422. esc$G$1:
  423.     mvi    b,10000000b        ; select alt character set
  424.     jr    set$atr$off
  425.  
  426. ;
  427. ;    Blinking On
  428. ;
  429. esc$B$2:        ; turn flash ON ???
  430. esc$G$2:    
  431.     mvi    b,00010000b        ; turn on blink attr
  432.     jr    set$atr$on
  433. ;
  434. ;
  435. ;
  436. esc$C$2:        ; turn flash OFF ???
  437.     mvi    b,00010000b
  438.     jr    set$atr$off
  439. ;
  440. ;    Under line
  441. ;
  442. esc$B$3:        ; turn underline ON ???
  443. esc$G$3:
  444.     mvi    b,00100000b        ; turn on underline bit
  445.     jr    set$atr$on
  446. ;
  447. ;
  448. ;
  449. esc$C$3:        ; turn under line OFF  ???
  450.     mvi    b,00100000b
  451.     jr    set$atr$off
  452. ;
  453. ;    Reverse Video On
  454. ;
  455. esc$B$0:
  456. esc$G$4:
  457.     mvi    b,01000000b        ; turn attributes on
  458.  
  459. set$atr$on:
  460.     mov    c,b            ; reverse attr
  461. set$FR$attr:
  462.     TJMP    FR$attr
  463.  
  464. ;
  465. ;
  466. ;
  467. esc$C$1:        ; turn half bright OFF ???
  468.     mvi    b,00000001b
  469.     jr    set$atr$on
  470.  
  471. ;
  472. ;
  473. ;
  474. esc$B$1:        ; set half bright ON ???
  475.     mvi    b,00000001b
  476.     jr    set$atr$off
  477.  
  478. ;
  479. ;    turn reverse video off
  480. ;
  481. esc$C$0:
  482.     mvi    b,01000000b        ; attribute to turn off
  483. set$atr$off:
  484.     mov    a,b
  485.     cma
  486.     ana    b
  487.     mov    c,a
  488.     TJMP    FR$attr
  489.  
  490.     page
  491. ;
  492. ;    table scanned top to bottom
  493. ;
  494. control$table:
  495.     db    07h    ; ^G        bell
  496.     db    bs    ; ^H        cursor left
  497.     db    lf    ; ^J        cursor down
  498.     db    0Bh    ; ^K        cursor up
  499.     db    0Ch    ; ^L        cursor right
  500.     db    cr    ; ^M        carrage return
  501.     db    1Ah    ; ^Z        home and clear screen
  502.     db    esc    ; ESC
  503.     db    18h    ; ^X        Clear to End of Line (K-Pro)
  504.     db    17h    ; ^W        Clear to End of Screen (K-Pro)
  505.     db    1Eh    ; ^^        home cursor (K-Pro)
  506.  
  507. cnt$tbl$lng    equ    $-control$table
  508.  
  509. ;
  510. ;    table scanned bottom to top
  511. ;
  512. control$exec$adr:
  513.     dw    home$cursor    ; ^^    home cursor    (K-Pro)
  514.     dw    esc$y        ; ^W    CES        (K-Pro)
  515.     dw    esc$t        ; ^X    CEL        (K-Pro)
  516.     dw    char$esc    ; ESC
  517.     dw    char$cnt$z    ; ^Z    home and clear screen
  518.     dw    do$cr        ; ^M    carriage return
  519.     dw    cursor$rt    ; ^L    cursor right
  520.     dw    cursor$up    ; ^K    cursor up
  521.     dw    cursor$down    ; ^J    cursor down
  522.     dw    cursor$left    ; ^H    cursor left
  523.     dw    char$cnt$g    ; ^G    bell
  524.  
  525.  
  526.     page
  527. ;
  528. ;    table scanned top to bottom
  529. ;
  530. esc$table:
  531.     db    '='        ; ESC = R C    
  532.  
  533.     db    'T'        ; ESC T      clear to end of line
  534.     db    't'        ; ESC t   clear to end of line
  535.     db    'Y'        ; ESC Y   clear to end of screen
  536.     db    'y'        ; ESC y   clear to end of screen
  537.     db    ':'        ; ESC :   home & clear screen
  538.     db    '*'        ; ESC *   home & clear screen
  539.  
  540.     db    'E'        ; ESC E   Insert line
  541.     db    'Q'        ; ESC Q   Insert Character
  542.     db    'R'        ; ESC R   Delete Line
  543.     db    'W'        ; ESC W   Delete Character
  544.  
  545.     db    ')'        ; ESC )   Half intensity on
  546.     db    '('        ; ESC (   Half intensity off
  547.     db    'G'        ; ESC G 4 Reverse video on
  548.                 ; ESC G 2 Blinking on
  549.                 ; ESC G 0 Rev. video and blinking off
  550.     db    'B'        ; ESC B <num> atribute on
  551.     db    'C'        ; ESC C <num> atribute off
  552.     db    esc        ; ESC ESC
  553.     db    'D'        ; ESC D   ???
  554.     db    'L'        ; ESC L   ???
  555.  
  556. esc$tbl$lng    equ    $-esc$table
  557.  
  558.  
  559. ;
  560. ;    table scanned bottom to top
  561. ;
  562. esc$exec$adr:
  563.     dw    esc$L        ; ESC L   A kaypro function ???
  564.     dw    esc$D        ; ESC D   A kaypro function ???
  565.     dw    esc$esc        ; ESC ESC ESC color
  566.     dw    esc$C        ; ESC C <num> atribute off
  567.     dw    esc$B        ; ESC B <num> atribute on
  568.     dw    esc$G        ; ESC G 4 Reverse video on
  569.                 ; ESC G 2 Blinking on
  570.                 ; ESC G 0 Rev. video and blinking off
  571.     dw    esc$lfp        ; ESC (   Half intensity off
  572.     dw    esc$rtp        ; ESC )   Half intensity on
  573.  
  574.     dw    esc$W        ; ESC W   Delete Character
  575.     dw    esc$R        ; ESC R   Delete Line
  576.     dw    esc$Q        ; ESC Q   Insert Character
  577.     dw    esc$E        ; ESC E   Insert line
  578.  
  579.     dw    char$cnt$z    ; ESC *   home & clear screen
  580.     dw    char$cnt$z    ; ESC :   home & clear screen
  581.     dw    esc$y        ; ESC y   clear to end of screen
  582.     dw    esc$y        ; ESC Y   clear to end of screen
  583.     dw    esc$t        ; ESC t   clear to end of line
  584.     dw    esc$t        ; ESC T      clear to end of line
  585.  
  586.     dw    esc$equ        ; ESC = RC
  587. ;
  588. ;
  589. ;
  590. esc$num$tbl:
  591.     dw    esc$b$0        ; ESC B0    reverse video ON
  592.     dw    esc$b$1        ; ESC B1 ???    half bright ON
  593.     dw    esc$b$2        ; ESC B2 ???    blink ON
  594.     dw    esc$b$3        ; ESC B3 ???    under line ON
  595.  
  596.     dw    esc$c$0        ; ESC C0    reverse video OFF
  597.     dw    esc$c$1        ; ESC C1 ???    half bright OFF
  598.     dw    esc$c$2        ; ESC C2 ???    blink OFF
  599.     dw    esc$c$3        ; ESC C3 ???    under line OFF
  600.  
  601.     dw    esc$g$0        ; ESC G0 clear attributes (all G functions)
  602.     dw    esc$g$1        ; ESC G1 alt char set
  603.     dw    esc$g$2        ; ESC G2 blink attr on
  604.     dw    esc$g$3        ; ESC G3 underline attr on
  605.     dw    esc$g$4        ; ESC G4 reverse video on
  606.  
  607.